package com.example.rsa;

import lombok.extern.slf4j.Slf4j;
//import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.spec.ECGenParameterSpec;

@Slf4j
//@Component
public class Sm2KeyPairProvider implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) {
        //ECGenParameterSpec sm2Spec = new ECGenParameterSpec("sm2p256v1");
        //KeyPairGenerator  sm2KeyGen = KeyPairGenerator.getInstance("EC", new BouncyCastleProvider());
        //sm2KeyGen.initialize(sm2Spec);
        //sm2KeyGen.initialize(sm2Spec, new SecureRandom());
        //KeyPair keyPair = sm2KeyGen.genKeyPair();
        /*String property = System.getProperty("user.dir");
        String str = "你好";
        String s1 = "D:\\Workspace\\IntelliJ-IDEA_Workspace\\req\\private-java";
        System.out.println(str.getBytes(StandardCharsets.UTF_8).length);
        String reg = "./user.dir";
        String s = reg.replaceFirst("\\.", "D:\\\\Workspace\\\\IntelliJ-IDEA_Workspace\\\\req\\\\private-java");
        System.out.println(s);*/
        String s = "str1";
        switch (s.length()) {
            case 4:
                if (s.equals("str1")) {
                    throw new RuntimeException();
                }
                break;
            case 2:
                System.out.println(s);
                break;
            default:
                break;
        }
    }
}
